{% extends 'promos/base.html' %}
{% load i18n %}

{% block title %}{{promo}} | Promos{% endblock %}

{% block extra_head %}
    {{ block.super }}
    {% if promo.get_geotags.point %}
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key={{ google_key }}" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function() {
        var map = new GMap2(document.getElementById('map'));
        map.setMapType(G_PHYSICAL_MAP);
        var point = new GLatLng({{ promo.get_geotags.point.0.point.y }}, {{ promo.get_geotags.point.0.point.x }});
        marker = new GMarker(point);
        map.setCenter(point, 15);
        map.addOverlay(marker);
        });
    </script>
    {% endif %}
{% endblock %}

{% block body_id %}promos{% endblock %}

{% block app_menu %}
<h2>Promos</h2>
<ul>
<li><a href="{% url promos_promo_edit promo.id %}">Edit Promo</a></li>
</ul>
{% endblock %}

{% block main_content %}
<h1>{{promo}}</h1>
<div class="edit-promo-tabs">
    <div class="tab-links">
        <a href="{% url promos_promo_edit promo_id=promo.id %}" rel="promo-info">Pitch</a>
        <a href="{% url promos_promo_add_edit_point promo_id=promo.id %}" rel="promo-info" title="Geotag">Geotag</a>
        <a href="{% url promos_promo_image_list promo_id=promo.id %}">Images</a>
        <a href="{% url promos_promo_link_list promo_id=promo.id %}">Related Links</a>
        <a href="{% url promos_promo_date_list promo_id=promo.id %}">Suggested Dates</a>
        <a href="{% url promos_promo_billboard_list promo_id=promo.id %}">Billboards</a>
        <a href="{% url promos_promo_detail promo_id=promo.id %}" class="active">Detail</a>
        <br class="clearboth" />
    </div>
    <div class="tab-contents">
    <h1>{{promo}}</h1>
    <p><a href="{{ promo.permalink }}">{{ promo.permalink }}</a></p>
    <p>{{promo.description}}</p>

    <h2>Geotag</h2>
    {% if promo.get_geotags.point %}
    <div id="map" style="height: 200px; width: 200px; -moz-border-radius: 5px; border: 3px solid #DDD;"></div>
    {% else %}
        <p>You haven't geotagged this promo yet.</p>
    {% endif %}


    <h2>Images</h2>
    {% if promo.promoimage_set.count %}
    <table cellspacing="0" cellpadding="0" class="list-table">
        <thead>
            <tr>
                <th class="id_col">Caption</th>
                <th>Attribution</th>
                <th>Kind</th>
            </tr>
        </thead>
        {% for promo_image in promo.promoimage_set.all %}
        <tr class="{% cycle '' 'alt-row' %}">
            <td><a href="{% url promos_promo_image_edit promo_id=promo.id,image_id=promo_image.id %}">{{ promo_image }}</a></td>
            <td>{{ promo_image.attribution }}</td>
            <td>{{ promo_image.get_image_kind_display }}</td>
        </tr>
        {% endfor %}
    </table>
    {% else %}
        <p>You haven't submitted any links yet.</p>
    {% endif %}

    <h2>Related Links</h2>
    {% if promo.promolink_set.count %}
    <table cellspacing="0" cellpadding="0" class="list-table">
        <thead>
            <tr>
                <th class="id_col">Site</th>
                <th>Description</th>
            </tr>
        </thead>
        {% for promo_link in promo.promolink_set.all %}
        <tr class="{% cycle '' 'alt-row' %}">
            <td><a href="{% url promos_promo_link_edit promo_id=promo.id,link_id=promo_link.id %}">{{ promo_link }}</a></td>
            <td>{{ promo_link.desc }}</td>
        </tr>
        {% endfor %}
    </table>
    {% else %}
        <p>You haven't submitted any links yet.</p>
    {% endif %}

    <h2>Dates</h2>

    {% if promo.promodate_set.count %}
    <table cellspacing="0" cellpadding="0" class="list-table">
        <thead>
            <tr>
                <th>Title</th>
                <th>Start date</th>
                <th>End date</th>
                <th>Description</th>
            </tr>
        </thead>
        {% for promo_date in promo.promodate_set.all %}
        <tr class="{% cycle '' 'alt-row' %}">
            <td><a href="{% url promos_promo_date_edit promo_id=promo.id,date_id=promo_date.id %}">{{ promo_date }}</a></td>
            <td>{{ promo_date.start_date }}</td>
            <td>{{ promo_date.end_date }}</td>
            <td>{{ promo_date.description }}</td>
        </tr>
        {% endfor %}
    </table>
    {% else %}
        <p>You haven't submitted any dates yet.</p>
    {% endif %}

    <h2>Billboards</h2>

    {% if promo.promobillboard_set.count %}
    <table cellspacing="0" cellpadding="0" class="list-table">
        <thead>
            <tr>
                <th class="id_col">Campaign</th>
                <th>Headline</th>
                <th>Supporting Text</th>
            </tr>
        </thead>
        {% for promo_billboard in promo.promobillboard_set.all %}
        <tr class="{% cycle '' 'alt-row' %}">
            <td><a href="{% url promos_promo_billboard_edit promo_id=promo.id,billboard_id=promo_billboard.id %}">{{ promo_billboard }}</a> </td>
            <td>{{ promo_billboard.headline }}</td>
            <td>{{ promo_billboard.supporting_text }}</td>
        </tr>
        {% endfor %}
    </table>
    {% else %}
        <p>You haven't submitted any billboards yet.</p>
    {% endif %}


    <br clear="all">
    </p>


    <h2>Additional Information</h2>
    <dt>Submitted by</dt>
    <dd><a href="{{ promo.submitter.get_absolute_url }}">{{promo.submitter}}</a></dd>
    <dt>Authors</dt>
    <dd>
    {{ promo.authors.all|join:", " }}
    </dd>
    </dl>
    </div>
</div>
{% endblock %}
{% block subnav %}
<h2>Links</h2>
<ul class="action-links">
    <li><a href="{% url promos_promo_list %}">promo list</a></li>
    <li><a href='{% url promos_promo_billboard_calendar_now promo_id=promo.id %}'>Calendar</a></li>
 </ul>
{% endblock %}


